public class demo07 {
    //平方和
    public static void main(String[] args) {
        long sum=0;
        for (int i = 1; i <= 2019; i++) {
            int tmp=i;
            while (tmp!=0){
                if(tmp%10==0||tmp%10==1||tmp%10==2||tmp%10==9){
                    sum+=i*i;
                    break;
                }
                tmp/=10;
            }
        }
        System.out.println(sum);
    }
}
